using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Arm : MonoBehaviour
{
    public Rigidbody2D root;
    public Glove glove;
    public List<float> springLength;
    public List<float> springFrequency;
    public List<SpringJoint2D> arms;

    private Rigidbody2D m_gloveRigidbody;
    private ParticleSystem.MainModule m_bubbleMain;

    private void Awake()
    {
        arms[0].connectedBody = root;
        glove.root = root.transform;
        for (int i = 0; i < 4; i++)
        {
            arms[i].frequency = springFrequency[i];
            arms[i].distance = springLength[i];
        }

        m_gloveRigidbody = glove.GetComponent<Rigidbody2D>();
        m_bubbleMain = GetComponentInChildren<ParticleSystem>().main;
    }

    private void Update()
    {
        var hasBubble = glove.InWater && m_gloveRigidbody.velocity.magnitude >= 15.0f;
        m_bubbleMain.startColor = hasBubble ? Color.white : Color.clear;
    }
}
